/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package lab6.Home;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

/**
 *
 * @author THIEN
 */
public class ComputerList {

    public ComputerList() {
    }
    ArrayList<Computer> ListComputer = new ArrayList<Computer>();

    public void addComputer(String Object) throws IOException {
        InputStreamReader ISR = new InputStreamReader(System.in);
        BufferedReader BR = new BufferedReader(ISR);
        String answer = "y";
        if(Object.equals("Computer"))
        {
        while (answer.equals("y") || answer.equals("Y")) {
            //Add computer
            System.out.println("Computer's infomation");
            System.out.print("Input computer's id: ");
            int id = Integer.parseInt(BR.readLine());

            System.out.print("\nInput computer's name: ");
            String name = BR.readLine();

            System.out.print("\nInput computer's price: ");
            double p = Double.parseDouble(BR.readLine());
            Double price = new Double(p);

            //add into list
            Computer computer = new Computer(id, name, price);
            ListComputer.add(computer);

            //ask for continue or not ?
            System.out.println("Are you want to continue (Y/N) ?");
            answer = BR.readLine();
        }
        Demo.subMenu("Computer");
        }
    }
    public void Display(String Object) throws IOException{
        if(Object.equals("Computer"))
        for(Computer computer: ListComputer){
            System.out.println(computer);
        }
        Demo.Menu();

    }
}
